package com.sds.replicator.transformers;

import java.io.UnsupportedEncodingException;

/**
 * Created by IntelliJ IDEA.
 * User: sdsbirdman
 * Date: 7/2/11
 * Time: 11:19 AM
 * To change this template use File | Settings | File Templates.
 */
public class CSSTransformer implements Transformer {
    private String localPath;

    public CSSTransformer(String localPath) {
        this.localPath = localPath;

    }

    @Override
    public String getContentType() {
        return "text/css";
    }

    @Override
    public byte[] transformContent(String encoding, byte[] content) throws UnsupportedEncodingException {
        String s = new String(content, encoding);
        s = s.replaceAll("url\\(", "url(" + localPath + "?url=");
        return s.getBytes(encoding);
    }
}
